package org.jeecg.entity.charge;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.util.StringUtils;
import org.jeecg.enums.charge.BillTypeEnum;
import org.jeecg.enums.common.PayTypeEnum;
import org.jeecg.modules.system.entity.BaseEntity;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 账单
 * @Author: jeecg-boot
 * @Date:   2019-08-08
 * @Version: V1.0
 */
@Data
@TableName("charge_bills")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="charge_bills对象", description="账单")
public class ChargeBills extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -4885169026251331154L;

    public ChargeBills(){}

    /**id*/
	@TableId(type = IdType.ID_WORKER_STR)
	@ApiModelProperty(value = "id")
	private String id;
	/**业主ID*/
	//@Excel(name = "业主ID", width = 15)
    @ApiModelProperty(value = "业主ID")
	private String customerId;
	/**租户ID*/
	//@Excel(name = "租户ID", width = 15)
    @ApiModelProperty(value = "租户ID")
	private String rentId;
    /**合同id*/
    @ApiModelProperty(value = "合同id")
	private String contractId;
	/**应收年月*/
	@Excel(name = "应收年月", width = 15)
    @ApiModelProperty(value = "应收年月")
	private String zjCny;
	/**应收金额*/
	@Excel(name = "应收金额", width = 15)
    @ApiModelProperty(value = "应收金额")
	private BigDecimal due;

	@ApiModelProperty("实收金额")
	private BigDecimal pay;

	//@Excel(name = "优惠减免金额", width = 15)
	@ApiModelProperty(value = "优惠减免金额")
	private BigDecimal payReduced;

	//@Excel(name = "缴费优惠金额", width = 15)
	@ApiModelProperty(value = "缴费优惠金额")
	private BigDecimal batchDiscountMoney;

	@ApiModelProperty(value = "账单类型：0普通账单  1折扣账单")
	private Integer billType;

	//@Excel(name = "账单类型", width = 15)
	@TableField(exist = false)
	@ApiModelProperty(value = "账单类型：0普通账单  1折扣账单")
	private String billTypeStr;

	@ApiModelProperty(value = "订单id")
	private String orderId;

	/**收费项目ID*/
	//@Excel(name = "收费项目ID", width = 15)
    @ApiModelProperty(value = "收费项目ID")
	private String feeitemId;
	/**收款日期*/
	@Excel(name = "收款日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "收款日期")
	private java.util.Date zjSkrq;
	/**差额单价*/
	//@Excel(name = "差额单价", width = 15)
    @ApiModelProperty(value = "差额单价")
	private Double zjCedj;
	/**结账日期*/
	//@Excel(name = "结账日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "结账日期")
	private java.util.Date zjJzrq;
	/**调整日期*/
	//@Excel(name = "调整日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "调整日期")
	private java.util.Date zjTzrq;
	/**退款日期*/
	@Excel(name = "退款日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "退款日期")
	private java.util.Date zjTkrq;
	/**补打日期*/
	//@Excel(name = "补打日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "补打日期")
	private java.util.Date zjBdrq;
	/**付款人员ID*/
	//@Excel(name = "付款人员ID", width = 15)
    @ApiModelProperty(value = "付款人员ID")
	private String payuserId;
	/**收款人员姓名*/
	@Excel(name = "收款人员姓名", width = 15)
    @ApiModelProperty(value = "收款人员姓名")
	private String payuserName;
	/**收费方式*/
    @ApiModelProperty(value = "收费方式")
	private Integer payType;

	@Excel(name = "收费方式", width = 15)
	@TableField(exist = false)
	private String payTypeStr;
	/**发票号码*/
	//@Excel(name = "发票号码", width = 15)
    @ApiModelProperty(value = "发票号码")
	private String invoiceNo;
	/**入库单编号*/
	//@Excel(name = "入库单编号", width = 15)
    @ApiModelProperty(value = "入库单编号")
	private String invoiceGrnno;
	/**开票日期*/
	//@Excel(name = "开票日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "开票日期")
	private java.util.Date makeinvoiceDate;
	/**上次抄见数*/
	//@Excel(name = "上次抄见数", width = 15)
    @ApiModelProperty(value = "上次抄见数")
	private Double lastReading;
	/**本次抄见数*/
	//@Excel(name = "本次抄见数", width = 15)
    @ApiModelProperty(value = "本次抄见数")
	private Double thisReading;
	/**抄表日期*/
	//@Excel(name = "抄表日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "抄表日期")
	private java.util.Date readingDate;
	/**电费单价*/
	//@Excel(name = "电费单价", width = 15)
    @ApiModelProperty(value = "电费单价")
	private Double unitPrice;
	/**实耗数*/
	//@Excel(name = "实耗数", width = 15)
    @ApiModelProperty(value = "实耗数")
	private Double elapsedNum;
	/**表具编号*/
	//@Excel(name = "表具编号", width = 15)
    @ApiModelProperty(value = "表具编号")
	private String tableId;
	/**退款号码*/
	//@Excel(name = "退款号码", width = 15)
    @ApiModelProperty(value = "退款号码")
	private String zjTkhm;
	/**退款说明*/
	//@Excel(name = "退款说明", width = 15)
    @ApiModelProperty(value = "退款说明")
	private String zjTksm;

	@ApiModelProperty(value = "拆分计数")
	private Integer billsNum;
	/**收入*/
	//@Excel(name = "收入", width = 15)
    @ApiModelProperty(value = "收入")
	private Double income;

	/**0：按月收费 , 1：单价乘以面积*/
	//@Excel(name = "0：按月收费 , 1：单价乘以面积", width = 15)
    @ApiModelProperty(value = "0：按月收费 , 1：单价乘以面积")
	private String feeType;
	/**税率*/
	//@Excel(name = "税率", width = 15)
    @ApiModelProperty(value = "税率")
	private Double taxRate;
	/**税额*/
	//@Excel(name = "税额", width = 15)
    @ApiModelProperty(value = "税额")
	private Double taxPaid;
	/**调整账单的上一次金额*/
//	@Excel(name = "调整账单的上一次金额", width = 15)
    @ApiModelProperty(value = "调整账单的上一次金额")
	private Double historicalJe;
	/**账单说明*/
	@Excel(name = "账单说明", width = 15)
    @ApiModelProperty(value = "账单说明")
	private String billsExp;
	/**日期范围*/
	//@Excel(name = "日期范围", width = 15)
    @ApiModelProperty(value = "日期范围")
	private String dateRange;
	/**账单单价*/
	@Excel(name = "账单单价", width = 15)
    @ApiModelProperty(value = "账单单价")
	private Double feePrice;
	/**项目ID*/
//	@Excel(name = "项目ID", width = 15)
    @ApiModelProperty(value = "项目ID")
	private String projectId;
	/**物业公司ID*/
	//@Excel(name = "物业公司ID", width = 15)
    @ApiModelProperty(value = "物业公司ID")
	private String tenantId;
	/**创建者*/
	//@Excel(name = "创建者", width = 15)
    @ApiModelProperty(value = "创建者")
	private String createBy;
	/**创建时间*/
	//@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
	private java.util.Date createTime;
	/**更新者*/
	//@Excel(name = "更新者", width = 15)
    @ApiModelProperty(value = "更新者")
	private String updateBy;
	/**更新时间*/
	//@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
	private java.util.Date updateTime;
	/**备注信息*/
	//@Excel(name = "备注信息", width = 15)
    @ApiModelProperty(value = "备注信息")
	private String remarks;
	/**删除标记*/
	//@Excel(name = "删除标记", width = 15)
    @ApiModelProperty(value = "删除标记")
	private String delFlag;

	@Excel(name = "项目名称", width = 15)
	@TableField(exist = false)
	private String projectName;

	@Excel(name = "楼宇名称", width = 15)
    @TableField(exist = false)
	private String floorName;

	@Excel(name = "房间名称", width = 15)
    @TableField(exist = false)
	private String roomName;
	/**
	 * 收费项目名
	 * */
	@Excel(name = "收费项目名", width = 15)
    @TableField(exist = false)
	private String feeName;

	@TableField(exist = false)
	private List<String> feeIdList;

	/**
	 * 业主姓名
	 * */
	@Excel(name = "业主姓名", width = 15)
    @TableField(exist = false)
	private String customerName;
	/**
	 * 租户姓名
	 * */
	@Excel(name = "租户姓名", width = 15)
	@TableField(exist = false)
	private String rentName;
	/**
	 * 是否销账
	 * */
	//@Excel(name = "是否销账", width = 15)
    @TableField(exist = false)
	private String zjSk;
	/**
	 * 临时存放对应的账单ID
	 * */
	@TableField(exist = false)
	private List<String> billIds;
	/**
	* 区分账单状态;
	* */
	@TableField(exist = false)
	private String disState;

	/**
	 * 业主与租户的ID集合
	 * */
	@TableField(exist = false)
	private String [] keys;

//	/**
//	 * 业主与租户类型区分
//	 * */
//	@TableField(exist = false)
//	private String  types;



	/**
	 * 拆分金额集合
	 * */
	@TableField(exist = false)
	private List<String> splitMoney;

	/**
	 * 账单状态集合;
	 * */
	@TableField(exist = false)
	private List<String> disStates;

	/**
	 * 账单数量;
	 * */
	@TableField(exist = false)
	private Integer num;

	/**
	 * 收费项目对应开票编号;
	 * */
	@TableField(exist = false)
	private String maintenanceCost;

	/**
	 * 账单Id集合;
	 * */
	private String parentBillsIds;

	/**
	 * 账单集合;
	 * */
	@TableField(exist = false)
	private List<ChargeBills> children;

	/**
	 * 是否关联退款状态;
	 * */
	@TableField(exist = false)
	private String status;

	/**
	 * 全额退款状态
	 * */
	@TableField(exist = false)
	private String statusAll;

	/**
	 * 楼宇编号
	 * */
	private String floorId;

	/**
	 * 地址
	 * */
	@TableField(exist = false)
	private String address;

	/**
	 * 房间编号集合
	 * */
	@TableField(exist = false)
	private  List<String> roomIds;

	/**
	 * 房间编号
	 * */
	private String roomId;

	/**
	 * 分页起始页
	 * */
	@TableField(exist = false)
	private Integer pageNo;

	/**
	 * 结束页
	 * */
	@TableField(exist = false)
	private Integer pageSize;

	/**
	 * 会计科目编号
	 * */
	@TableField(exist = false)
	private String subjectsCode;

	@TableField(exist = false)
	private String createName;

	@TableField(exist = false)
	private List<String> ids;
	//是否拆合账单
    @TableField(exist = false)
	private Integer isSm;
	@TableField(exist = false)
	@ApiModelProperty(name = "合并收款的账单id集合-逗号分隔的字符串")
	@JsonIgnore
	private String mergeBillsId;
	@TableField(exist = false)
	@ApiModelProperty(name = "合并收款的账单id集合-list形式")
	private List<String> mergeBillsIdArr;

	public List<String> getMergeBillsIdArr() {
		if (StringUtils.isBlank(mergeBillsId)){
			return null;
		}
		this.mergeBillsIdArr = Arrays.asList(mergeBillsId.split(","));
		return mergeBillsIdArr;
	}


	public String getPayTypeStr() {
		return PayTypeEnum.getDesc(this.payType);
	}

	public String getBillTypeStr() {
		return BillTypeEnum.getDesc(this.billType);
	}

}
